<template>
  <d2-container>
    <div class="d2-breadcrumb">
      <el-breadcrumb separator-class="el-icon-arrow-right">
        <el-breadcrumb-item>企业管理</el-breadcrumb-item>
      </el-breadcrumb>
    </div>
    <el-form :inline="true" class="SearchForm" label-width="110px">
      <el-row :gutter="20">
        <el-col :span="8">
          <el-form-item label="企业名称">
            <el-input
              placeholder="请输入"
              type="text"
              v-model.trim="searchForm.name"
              clearable
            ></el-input>
          </el-form-item>
        </el-col>
        <el-col :span="8">
          <el-form-item label="社会信用代码">
            <el-input
              placeholder="请输入"
              type="text"
              v-model.trim="searchForm.creditCode"
              clearable
            ></el-input>
          </el-form-item>
        </el-col>
        <el-col :span="8">
          <el-form-item label="法定代表人">
            <el-input
              placeholder="请输入"
              type="text"
              v-model.trim="searchForm.legalPerson"
              clearable
            ></el-input>
          </el-form-item>
        </el-col>
        <el-col :span="8">
          <el-form-item label="运营人姓名">
            <el-input
              placeholder="请输入"
              type="text"
              v-model.trim="searchForm.operateName"
              clearable
            ></el-input>
          </el-form-item>
        </el-col>
        <el-col :span="8">
          <el-form-item label="运营人联系方式">
            <el-input
              type="text"
              v-model.trim="searchForm.operatePhone"
              clearable
            ></el-input>
          </el-form-item>
        </el-col>
        <el-col :span="8">
          <el-form-item label="关联园区">
            <el-input
              type="text"
              v-model.trim="searchForm.gardenName"
              clearable
            ></el-input>
          </el-form-item>
        </el-col>
        <el-col :span="8">
          <el-form-item label="关联主账号Id">
            <el-input type="text" v-model.trim="searchForm.userId" clearable></el-input>
          </el-form-item>
        </el-col>
        <el-col :span="8">
          <el-form-item label="认证状态">
            <el-select v-model="searchForm.checkStatus" placeholder="请选择" style="width: 207px">
              <el-option label="待审核" :value="0"></el-option>
              <el-option label="审核通过" :value="1"></el-option>
              <el-option label="拒绝" :value="2"></el-option>
            </el-select>
          </el-form-item>
        </el-col>
        <el-col :span="8">
          <el-button type="primary" @click="search()" icon="el-icon-search" style="margin-left: 10px"
            >查询</el-button
          >
          <el-button type="danger" icon="el-icon-refresh" @click="reset"
            >重置</el-button
          >
            <router-link to="company/add" >
              <el-button type="success" style="margin: 10px">新增企业</el-button>
            </router-link>
        </el-col>
      </el-row>
    </el-form>

    <el-table border :data="tableData.list">
      <el-table-column label="ID" align="center" prop="id"></el-table-column>
      <el-table-column
        label="公司名称"
        align="center"
        prop="name"
      ></el-table-column>
      <el-table-column
        label="统一社会信用代码"
        align="center"
        prop="creditCode"
      ></el-table-column>
      <el-table-column
        label="法定代表人"
        align="center"
        prop="legalPerson"
      ></el-table-column>
      <el-table-column
        label="法定代表人联系方式"
        align="center"
        prop="phone"
      ></el-table-column>
      <el-table-column
        label="运营人姓名"
        align="center"
        prop="operateName"
      ></el-table-column>
      <el-table-column
        label="运营人联系方式"
        align="center"
        prop="operatePhone"
      ></el-table-column>
      <el-table-column label="认证状态" align="center" prop="checkStatus">
        <template slot-scope="scope">
          {{ ["待审核", "审核通过", "拒绝"][scope.row.checkStatus] }}
        </template>
      </el-table-column>
      <el-table-column
        label="关联主账号UID"
        align="center"
        prop="userId"
      ></el-table-column>
      <el-table-column
        label="关联园区名称"
        align="center"
        prop="gardenName"
      ></el-table-column>
      <el-table-column label="操作" align="center" fixed="right">
        <template slot-scope="scope">
          <router-link :to="`/company/edit/${scope.row.id}`">
            <el-button type="text">查看/编辑</el-button>
          </router-link>
        </template>
      </el-table-column>
    </el-table>
    <el-pagination
      @size-change="search"
      @current-change="search"
      :current-page.sync="page"
      :page-sizes="[10, 25, 50, 100]"
      :page-size.sync="pageSize"
      layout="total, sizes, prev, pager, next, jumper"
      :total="tableData.total"
    ></el-pagination>
  </d2-container>
</template>

<script>
export default {
  name: "",
  data() {
    return {
      searchForm: {
        user_name: "",
      },
      tableData: {
        list: [],
        total: 0,
      },
      page: 1,
      pageSize: 10,
    };
  },
  methods: {
    search() {
      let params = {
        pageNum: this.page,
        pageSize: this.pageSize,
        ...this.searchForm,
      };

      this.$axios.post("/wxEnterprise/list", params).then((result) => {
        if (result) {
          this.tableData = {
            list: result.data.list,
            total: result.data.total,
          };
        } else {
          this.$message.error(result.data.msg);
        }
      });
    },
    reset() {
      this.searchForm = {};
      this.search();
    },
  },
  created() {
    this.search();
  },
};
</script>

<style scoped lang="scss">
</style>
